﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Leikjavefurinn.Repo;

namespace Leikjavefurinn.Controllers
{
    public class TTTController : Controller
    {
        [HandleError]
		public ActionResult Index(Guid id)
		{
             
			 TicTacToeRepo repo = new TicTacToeRepo();
			 GameDBDataContext _db = new GameDBDataContext();

			var this_game = repo.GetGameByID(id);

			//ef leikurinn er TIL þá er hann sendur inn í viewið. (!= null)
			//ef notandi er loggaður inn þá er leikurinn sendur innn
            if (this_game != null && User.Identity.IsAuthenticated == true)
            {
                 return View(this_game);
            }

			return RedirectToAction("Error", "Shared"); //Ath laga !!!!
        }

		public ActionResult About()
		{
			return View();
		}

		public ActionResult Create()
		{
			return View();
		}
    }
}
